package com.solotiger.douban.util;

import android.os.Environment;

import com.solotiger.douban.common.GlobalContants;

import java.io.File;

public class FileUtil {

    public static void fileInit() {

        File file = new File(GlobalContants.GLOBAL_CACHE_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }

        File thumbFile = new File(GlobalContants.GLOBAL_THUMB_PATH);
        if (!thumbFile.exists()) {
            thumbFile.mkdirs();
        }

        File nomedia = new File(GlobalContants.GLOBAL_THUMB_PATH + File.separator + ".nomedia");
        if (!nomedia.exists()) {
            try {
                nomedia.createNewFile();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        File sdcard = Environment.getExternalStorageDirectory();
        if (sdcard != null) {
            File mediaDir = new File(sdcard, "DCIM/Camera");
            if (!mediaDir.exists()) {
                mediaDir.mkdirs();
            }
        }

        File photoDir = new File(GlobalContants.GLOBAL_PHOTO_PATH);
        if (!photoDir.exists()) {
            photoDir.mkdirs();
        }
    }
}
